package com.test.order.service.impl;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.test.api.People;
import com.test.api.feign.UserClient;
import com.test.order.domain.po.Order;
import com.test.order.mapper.OrderMapper;
import com.test.order.service.IOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
@RequiredArgsConstructor
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements IOrderService {
//    private final RestTemplate restTemplate;
    private final UserClient userClient;
    @Override
    public Order findById(Long id) {
        Order order = getById(id);
//        People user = restTemplate.getForEntity("http://localhost:8080/user/" + order.getUserId(), People.class).getBody();
        People user = userClient.getUser(order.getUserId());
        order.setUser(user);
        return order;
    }
}
